#ifndef _UNRE_DEC_API_H_
#define _UNRE_DEC_API_H_
#if (defined WIN32 || defined _WIN32) 
#  define UNREDEC_API __declspec(dllexport)
#elif defined __GNUC__ && __GNUC__ >= 4
#  define UNREDEC_API 
#else
#  error "Platform not supported!"
#endif
#define __SHOW_TIME__ 1
#if __SHOW_TIME__>0
static long  start_time;
static long  stop_time;
#define TIMESTART {start_time = clock() ;}
#define TIMEEND(s) {stop_time = clock();std::cout<<s<<" cost(s) : "<<((float)stop_time-start_time)/CLOCKS_PER_SEC<<std::endl;}
#else
#define TIMESTART {}
#define TIMEEND(s) {}
#endif // __SHOW_TIME__>0 
#define DLL 0

#define SPLITCPUONLY

enum RETCODE
{
    OK = 0X0000, 
    GPU_IDX_ERR=0X0001,
    GPU_NOT_INIT = 0X0002,
    GPU_OUT_RANGE = 0X0003,
    GPU_INIT_ERR = 0X0004,
    GPU_GETDEVICE_ERR = 0X0005,
    GPU_ANOTHER_ERR = 0X0006,
    MEM_SPACE_FULL = 0X0010,
    FILE_ERR = 0X0011,
    DEC_HEIGHTWDITH_ERR = 0X0012,
    DEC_DEPTH_NOT_8 = 0X0013,
    DEC_UNSUPPORT_RAWDATATYPE = 0X0014,
    DEC_UNSUPPORT_FRAME = 0X0015,
    DEC_ANOTHER_ERR = 0X0016,
    PARAM_CROP_ERR = 0X0020,
    PARAM_RESIZE_ERR = 0X0021,
};
struct decoderParam
{
    int jump;
    int lmtMB;
    int rawDataType;  //0:YUVI420  1:BGR_CHW  2:RGB_CHW   3:BGR_HWC  4:RGB_HWC
    int retDecodeHeigth;
    int retDecodeWidth;
    int retFrameSize;
    int retOutCnt;
    int retFps;
    int retMemFrameNum;
    int cropRight;
    int cropLeft;
    int cropBottom;
    int cropTop;
    int resizeH;
    int resizeW;
    int memWithTimestamp; //0:no Timestamp  other: yes
    int retMemTimestampOffset;
    long long startTime;
    long long retEndTime;
};

extern "C"
{
#ifndef SPLITCPUONLY
    UNREDEC_API int DecoderInit2(int iGpu);
    UNREDEC_API int DecoderFile(int gpuIdx, char* fileIn, char* fileOut, struct decoderParam* pStruct);
    UNREDEC_API int DecoderMem2(int gpuIdx, char* fileIn, char* mem, struct decoderParam* pStruct);
    UNREDEC_API int splitMp4(char* mp4Path, char* outPath, struct decoderParam* pStruct);
    UNREDEC_API int DecoderDestroy2();
     UNREDEC_API int Open2(int gpuIdx, char* fileIn, struct decoderParam* pStruct);
      UNREDEC_API int DecoderMem3(int gpuIdx, char* mem, struct decoderParam* pStruct);
    UNREDEC_API int DecoderInit(int iGpu);
    UNREDEC_API int DecoderDestroy();
#endif
    UNREDEC_API int splitMp4C(char* fileIn, char* outPathTemplate, int nSeg);
}
#endif
